home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PROGRAMM / ASSEMBLE / H145.ZIP / ASXXXX_3.ZIP / LKHEAD.C < prev    next >
C/C++ Source or Header  |  1990-07-18  |  1KB  |  80 lines

  1. /* lkhead.c */
  2.  
  3. /*
  4.  * (C) Copyright 1989,1990
  5.  * All Rights Reserved
  6.  *
  7.  * Alan R. Baldwin
  8.  * 721 Berkeley St.
  9.  * Kent, Ohio  44240
  10.  */
  11.  
  12. #include <stdio.h>
  13. #include <string.h>
  14. #include <alloc.h>
  15. #include "aslink.h"
  16.  
  17. /*
  18.  * Create a new header entry.
  19.  *
  20.  * H n areas n global symbols
  21.  *   |       |
  22.  *   |       `---- hp->h_nglob
  23.  *   `------------ hp->h_narea
  24.  *
  25.  */
  26. VOID
  27. newhead()
  28. {
  29.     register i;
  30.     struct head *thp;
  31.  
  32.     hp = (struct head *) new (sizeof(struct head));
  33.     if (headp == NULL) {
  34.         headp = hp;
  35.     } else {
  36.         thp = headp;
  37.         while (thp->h_hp)
  38.             thp = thp->h_hp;
  39.         thp->h_hp = hp;
  40.     }
  41.     /*
  42.      * Set file pointer
  43.      */
  44.     hp->h_lfile = cfp;
  45.     /*
  46.      * Evaluate and build Area pointer list
  47.      */
  48.     i = hp->h_narea = eval();
  49.     if (i)
  50.         hp->a_list = (struct areax **) new (i*sizeof(struct areax *));
  51.     /*
  52.      * Evaluate and build Global symbol pointer list
  53.      */
  54.     skip(-1);
  55.     i = hp->h_nglob = eval();
  56.     if (i)
  57.         hp->s_list = (struct sym **) new (i*sizeof(struct sym *));
  58.     /*
  59.      * Setup Absolute DEF linkage.
  60.      */
  61.     lkparea(_abs_);
  62.     ap->a_flag = A_ABS|A_OVR;
  63. }
  64.  
  65. /*
  66.  * Module Name
  67.  */
  68. VOID
  69. module()
  70. {
  71.     char id[NCPS];
  72.  
  73.     if (headp) {
  74.         getid(id, -1);
  75.         strncpy(hp->m_id, id, NCPS);
  76.     } else {
  77.         fprintf(stderr, "No header defined\n");
  78.     }
  79. }
  80.